package com.example.demo.model;

import com.baidu.bas.annotation.Erupt;
import com.baidu.bas.annotation.EruptField;
import com.baidu.bas.annotation.sub_field.Edit;
import com.baidu.bas.annotation.sub_field.View;
import com.baidu.bas.upms.model.base.HyperModel;
import com.example.demo.enums.WidgetCategory;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;

/**
 * @author liuzhenchuan@foxmail.com
 * @date 2021/1/1
 */
@Setter
@Getter
@Erupt(name = "分组")
@Table(name = "ma_graph_widget",uniqueConstraints = {
        @UniqueConstraint(columnNames = "name")
})
@Entity
@NoArgsConstructor
public class Widget extends HyperModel {
    /**
     * 标识,eg: send_email, ABTest, waiting
     */
    @EruptField(
            views = @View(title = "标识"),
            edit = @Edit(title = "标识")
    )
    String name;
    /**
     * 中文名称
     */
    @EruptField(
            views = @View(title = "中文名称"),
            edit = @Edit(title = "中文名称")
    )
    String cname;

    @EruptField(
            views = @View(title = "英文名称"),
            edit = @Edit(title = "英文名称")
    )
    String ename;
    /**
     * 描述
     */
    @EruptField(
            views = @View(title = "描述"),
            edit = @Edit(title = "描述")
    )
    String description;
    @EruptField(
            views = @View(title = "图标"),
            edit = @Edit(title = "图标")
    )
    String icon;
    /**
     * 类别
     */
    @EruptField(
            views = @View(title = "类别"),
            edit = @Edit(title = "类别")
    )
    @Enumerated(value = EnumType.STRING)
    WidgetCategory category;

    @EruptField(
            views = @View(title = "排序位置"),
            edit = @Edit(title = "排序位置")
    )
    Integer position = 100;

    public Widget(String name, String cname, String icon, WidgetCategory category) {
        this.name = name;
        this.cname = cname;
        this.icon = icon;
        this.category = category;
    }

    @EruptField(
            views = @View(title = "是否开启"),
            edit = @Edit(title = "是否开启")
    )
    Boolean enable = true;


}
